import request from "../../request";
import type { TradeMark, TradeMarkResponseData } from "./type";

// 接口地址
enum API {
  TRADEMARK_URL = "/admin/product/baseTrademark/", // 获取已有品牌的地址
  ADDTRADEMARK_URL = "/admin/product/baseTrademark/save", // 保存
  UPDATETRADEMARK_URL = "/admin/product/baseTrademark/update", // 更新
  DELETE_URL = "/admin/product/baseTrademark/remove/", // 删除
}

// 获取已有品牌的接口方法
// page:获取第几页 ---默认第一页
// limit：每次获取几条数据
export const reqHasTradeMark = (page: number, limit: number) =>
  request.get<any, TradeMarkResponseData>(
    API.TRADEMARK_URL + `${page}/${limit}`,
  );

export const reqAddOrUpdateTrademark = (data: TradeMark) => {
  if (data.id) {
    return request.put<any, any>(API.UPDATETRADEMARK_URL, data);
  } else {
    return request.post<any, any>(API.ADDTRADEMARK_URL, data);
  }
};

export const reqDeleteTrademark = (id: number) =>
  request.delete<any, any>(API.DELETE_URL + id);
